const mysql = require('mysql')
let opt = {
    user:'xz',
    port:3306,
    password:'ytmx10086',
    host:'39.103.238.144',
    database:'xz'
}
const connect = mysql.createPool(opt)

connect.getConnection(err=>{
    if(err) {throw err}
    else{console.log('数据库连接成功！！');}
})


const getMysql = function(sql,arg1,arg2){
    return new Promise((resolve,reject)=>{
        connect.query(sql,[arg1,arg2],(err,data)=>{
            if(err){
                reject(err)
            }else{
                resolve(data)
            }
        })
    })
}

module.exports = getMysql
